// pages/feedback/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabs:[
      {
        id:0,
        value:"体验问题",
        isActive:true
      },
      {
        id:1,
        value:"商品、商家投诉",
        isActive:false
      },
    ],
    chooseImage:[],
    // 文本域内容
    textVal:""
  },

  
  // 标题点击事件
  tabsItemChange(e){
    // 1获取被点击的索引
    const {index}= e.detail;
    // 2修改原数组
    let {tabs}=this.data;
    tabs.forEach((v,i)=>i===index?v.isActive=true:v.isActive=false);
    // 赋值到data中
    this.setData({
      tabs
    })
  },
  // 点击+获取图片
  hadleChooseImg(){
    wx.chooseImage({
      count: 9,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success: (result) => {
        console.log(result);
        this.setData({
          chooseImage:[...this.data.chooseImage,...result.tempFilePaths]
        })
      },
    });
      
  },
  // 点击删除图片
  handleRemoveImg(e){
    const {index}=e.currentTarget.dataset;
    // console.log(index);
    let {chooseImage}=this.data;
    chooseImage.splice(index,1);
    this.setData({
      chooseImage
    })
  },
  // 文本域输入事件
  handleTextInput(e){
    this.setData({
      textVal:e.detail.value

    })
  },
  // 提交按钮的提交
  handleFormSubmit(){
    const {textVal}= this.data;
    if(!textVal.trim()){
      wx.showToast({
        title: '输入不合法',
        icon: 'none',
        mask: true
      });
      return;
        
    }
    
    wx.uploadFile({
      url: '',
      filePath: ,
      name: ,
      formData: {},
      success: (result) => {
        
      },
      fail: () => {},
      complete: () => {}
    });
      
  }
})